/*
 * sm_debug.h
 *
 *  Created on: Jul 16, 2012
 *      Author: Eugene Parkhomenko
 */

#if !defined(__SM_DEBUG_H__)
#define __SM_DEBUG_H__

#include <stdio.h>
#include "sm_types.h"


#define LEVEL_INFO      "<INFO>"
#define LEVEL_DEBUG     "<DEBUG>"
#define LEVEL_WARRNING  "<WARRNING>"
#define LEVEL_ERROR     "<ERROR>"

#define SM_DBG(EXTENDED, ...)                                       \
do                                                                  \
{                                                                   \
    if (FALSE != EXTENDED)                                          \
    {                                                               \
        printf("%s %s [%d] ", __FUNCTION__, __FILE__, __LINE__);    \
    }                                                               \
    printf("%s ", LEVEL_DEBUG);                                     \
    printf(__VA_ARGS__);                                            \
} while(0)

#define SM_ERR(EXTENDED, ...)                                       \
do                                                                  \
{                                                                   \
    if (FALSE != EXTENDED)                                          \
    {                                                               \
        printf("%s %s [%d] ", __FUNCTION__, __FILE__, __LINE__);    \
    }                                                               \
    printf("%s ", LEVEL_ERROR);                                      \
    printf(__VA_ARGS__);                                            \
} while(0)

#define SM_WARN(EXTENDED, ...)                                      \
do                                                                  \
{                                                                   \
    if (FALSE != EXTENDED)                                          \
    {                                                               \
        printf("%s %s [%d] ", __FUNCTION__, __FILE__, __LINE__);    \
    }                                                               \
    printf("%s ", LEVEL_WARRNING);                                  \
    printf(__VA_ARGS__);                                            \
} while(0)

#define SM_INFO(EXTENDED, ...)                                      \
do                                                                  \
{                                                                   \
    if (FALSE != EXTENDED)                                          \
    {                                                               \
        printf("%s %s [%d] ", __FUNCTION__, __FILE__, __LINE__);    \
    }                                                               \
    printf("%s ", LEVEL_INFO);                                      \
    printf(__VA_ARGS__);                                            \
} while(0)


/*******************************************************************
 *
 *                       New Line ended macroses
 *
 *******************************************************************/

#define SM_DBGNL(EXTENDED, ...)                                     \
do                                                                  \
{                                                                   \
    SM_DBG(EXTENDED, __VA_ARGS__);                                  \
    printf("\n");                                                   \
} while (0)

#define SM_ERRNL(EXTENDED, ...)                                     \
do                                                                  \
{                                                                   \
    SM_ERR(EXTENDED, __VA_ARGS__);                                  \
    printf("\n");                                                   \
} while (0)

#define SM_WARNNL(EXTENDED, ...)                                     \
do                                                                  \
{                                                                   \
    SM_WARN(EXTENDED, __VA_ARGS__);                                  \
    printf("\n");                                                   \
} while (0)

#define SM_INFONL(EXTENDED, ...)                                     \
do                                                                  \
{                                                                   \
    SM_INFO(EXTENDED, __VA_ARGS__);                                  \
    printf("\n");                                                   \
} while (0)
#endif /* __SM_DEBUG_H__ */
